from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Host(models.Model):
    ip = models.IPAddressField()
    idc = models.CharField(max_length=20)
    name = models.CharField(max_length=50)

    def __unicode__(self):
        return "%s [%s]" % (self.name, self.ip)

    def __str__(self):
        return "%s [%s]" % (self.name, self.ip)


class Product(models.Model):
    name = models.CharField(max_length=20)
    #pm = models.ForeignKey(User, blank=True)
    #rd = models.ForeignKey(User, blank=True)
    op = models.ForeignKey(User, blank=True)
    ppid = models.IntegerField()

    def __unicode__(self):
        return u"%s" % self.name

    def __str__(self):
        return "%s" % self.name

class Host2Pro(models.Model):
    hid = models.ForeignKey(Host)
    pid = models.ForeignKey(Product)

    def __unicode__(self):
        return u"%s-%s" % (self.hid, self.pid)

    def __str__(self):
        return "%s-%s" % (self.hid, self.pid)


class HostChange(models.Model):
    pid = models.ForeignKey(Product)
    hid = models.ForeignKey(Host)
    flag = models.CharField(max_length=10)

